/**
 * 保存选择审批数据
 * @param currentType 组件类型
 * @param nodeId 节点ID
 * @param selectDataList 数据
 * @returns {*[]}
 */
export function assignSelect(currentType, nodeId, selectDataList) {
  const mapItem = (item, idKey, nameKey) => ({id: item[idKey], name: item[nameKey], nodeId: nodeId});
  let selectAssignList = [];

  if ("role" === currentType) {
    selectAssignList = selectDataList.map(item => mapItem(item, 'roleId', 'roleName'));
  } else if ("dept" === currentType) {
    selectAssignList = selectDataList.map(item => mapItem(item, 'id', 'label'));
  } else if ("post" === currentType) {
    selectAssignList = selectDataList.map(item => mapItem(item, 'postId', 'postName'));
  } else if ("assignee" === currentType || "users" === currentType) {
    selectAssignList = selectDataList.map(item => mapItem(item, 'userId', 'nickName'));
  }

  return selectAssignList;
}
